<template>
  <div class="login">
    <div class="login-container">
      <div class="login-wraper">
        <div class="signin-wrapper">
          <span class="title">{{ currenType }}登录</span>
          <!-- 注意这里有一个通用组件：负责表单的验证 -->
          <component @cancelLoading="docancle" :is="currenComponent" ref="loginRef" />
          
          <div class="form-btn-container" v-show="loginType !== 1">
            <div class="form-btn-wrap">
              <div class="btn-bg"></div>
              <button class="form-btn" @click="doLogin">
                {{ btnText }}<i class="el-icon-loading" v-show="isLoading"></i>
              </button>
            </div>
          </div>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
import LoginByAccount from "@/components/login/LoginByAccount";

export default {
  components: { LoginByAccount },
  data() {
    return {
      isLoading: false,
      loginType: 0,
      loginComponent: ["LoginByAccount"],
      type: ["小雨云听"],
      picUrl: require("@/assets/img/login.jpg"),
    };
  },
  computed: {
    btnText() {
      return this.isLoading ? "登录中" : "登录";
    },
    currenComponent() {
      return this.loginComponent[this.loginType];
    },
    currenType() {
      return this.type[this.loginType];
    },
  },
  methods: {
    /* 账号密码登录 */
    doLogin() {
      if (this.loginType === 0 || this.loginType === 2) {
        this.isLoading=true
        this.$refs.loginRef.doLogin();//这个组件上的doLogin方法。
      }
    },
    docancle(bool){
      this.isLoading=bool
    }
  },
};
</script>

<style lang="less" scoped>
.login {
  width: 100%;
  margin: 0 auto;
  overflow: hidden;
  .login-container {
    display: flex;
    justify-content: center;
    align-items: center;
    position: relative;
    min-height: 100vh;
    background-image: url("../assets/img/loginback2.jpg");
    background-repeat: no-repeat;
    background-size: cover;
    background-color: #2e7eee;
  }
}
.login-wraper {
  min-height: 537px;
  // background-image: url("../assets/img/img-banner-bg.png");
  background-repeat: no-repeat;
  padding-left: 34vw;
}
.signin-wrapper {
  width: 400px;
  height: 560px;
  border-radius: 10px;
  padding: 65px 55px 54px 55px;
  background: rgba(255,255,255,.2);
  border-left: 2px solid rgba(255,255,255,0.7);
  border-top: 2px solid rgba(255,255,255,0.7);
  border-radius: 20px;
  /* 主要地方:背景滤镜 */
  backdrop-filter: blur(2px);
  box-shadow: 5px 5px 20px rgba(255,255,255,.8);

  .title {
    display: block;
    font-size: 30px;
    color: #423d3d;
    line-height: 1.2;
    text-align: center;
    padding-bottom: 49px;
  }
}
.form-btn-container {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  margin-top: 50px;
  .form-btn-wrap {
    width: 100%;
    display: block;
    position: relative;
    z-index: 1;
    border-radius: 25px;
    overflow: hidden;
    margin: 0 auto;
    &:hover .btn-bg {
      background-position-x: 200px;
    }
    .btn-bg {
      position: absolute;
      z-index: -1;
      width: 300%;
      height: 100%;
      background: #4b75f4;
      background: -webkit-linear-gradient(
        right,
        #00de26,
        #2196f3,
        #00debc,
        #0040ff
      );
      top: 0;
      left: -100%;
      transition: all 0.5s;
    }
    .form-btn {
      font-size: 16px;
      color: #fff;
      line-height: 1.2;
      text-transform: uppercase;
      display: flex;
      justify-content: center;
      align-items: center;
      padding: 0 20px;
      width: 100%;
      height: 50px;
      outline: none;
      border: none;
      background: transparent;
      cursor: pointer;
    }
  }
}
@media screen and (max-width: 576px) {
  .login-container {
    padding-left: 15px;
    padding-right: 15px;
  }
}
</style>
